/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dao;

import com.common.CommonBase;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author NguyenVan
 */
public class ConnectionDB {

    CommonBase commonbase=new CommonBase();
    
    public ConnectionDB() {
        
    }

    public Connection ConnectionDatabase() throws SQLException {
        try {
            Class.forName(commonbase.JDBC_DRIVER);
            return DriverManager.getConnection(commonbase.DB_URL, commonbase.USER, commonbase.PASS);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ConnectionDB.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
    
//    public static void main(String[] args) {
//        try {
//            
//            ConnectionDB c=new ConnectionDB();
//            Connection  cn=c.ConnectionDatabase();
//            if(cn!=null){
//                System.out.println("connection true");
//            }else{
//                System.out.println("connection false");
//            }
//        } catch (SQLException ex) {
//            Logger.getLogger(ConnectionDB.class.getName()).log(Level.SEVERE, null, ex);
//        }
//    }

}
